<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
$api = app('Dingo\Api\Routing\Router');


$api->version('v1', function ($api) {
    $api->group(['namespace'=>'App\Http\Controllers\Api','middleware'=>['cors']],function ($api){
        $api->post('user/login','UserController@login');
        $api->get('user/not_found','UserController@not_found');
        $api->post('user/regist','UserController@regist');
        $api->post('user/regist_code','UserController@regist_code');
        $api->post('user/reset_code','UserController@reset_code');
        $api->post('user/reset_password','UserController@reset_password');


        //全国地址
        $api->get('addr/all','AddrController@all');


        $api->get('banner/lists','HomeController@banner_lists');
        $api->get('banner/detail','HomeController@banner_detail');

        //首页
        $api->get('home/hot_goods','HomeController@hot_goods');
        $api->get('home/like_goods','HomeController@like_goods');
        //搜索
        $api->get('home/search','HomeController@search');
        //关于我们
        $api->get('home/aboutus','HomeController@aboutus');
        //积分规则
        $api->get('home/interule','HomeController@interule');
        //版本
        $api->get('home/version','HomeController@version');

        $api->get('goods/detail','GoodsController@detail');
        $api->post('goods/lists','GoodsController@lists');
        $api->get('goods/all','GoodsController@all');

        $api->post('classify/lists','ClassifyController@lists');

        $api->group(['middleware'=>['token']], function ($api) {

            $api->post('user/info','UserController@user_info');
            $api->post('user/edit','UserController@edit');
            $api->post('user/h5_edit','UserController@h5_edit');
            $api->post('user/share','UserController@share');

            $api->post('collection/lists','CollectionController@lists');
            $api->post('collection/create','CollectionController@create');
            $api->post('collection/destory','CollectionController@destory');


            $api->post('addr/lists','AddrController@lists');
            $api->post('addr/is_default','AddrController@is_default');
            $api->post('addr/create','AddrController@create');
            $api->post('addr/del','AddrController@del');
            $api->post('addr/edit','AddrController@edit');

            $api->post('shopcar/create','ShopcarController@create');
            $api->post('shopcar/lists','ShopcarController@lists');
            $api->post('shopcar/destory','ShopcarController@destory');
            $api->post('shopcar/num','ShopcarController@num');

            $api->post('order/lists','OrderController@lists');
            $api->post('order/create','OrderController@create');
            $api->post('order/confirm','OrderController@confirm');

            $api->post('order/update','OrderController@update');

            $api->post('order/detail','OrderController@detail');
            $api->post('order/update','OrderController@update');

            $api->post('user/intergral_detail','UserController@intergral_detail');//积分明细
        });
    });
    $api->group(['namespace'=>'App\Http\Controllers','middleware'=>['cors']],function ($api){
        $api->any('pay/detail','NotifyController@order_detail');
        $api->post('alipay/create','NotifyController@alipay_create');
        $api->any('wechat/create','NotifyController@wechat_create');



    });

});